#!/usr/bin/python3
#coding=utf8
#测试
port = 21
banner = "FreeFloat FTP Server"

##<class 'str'>
print("[+] checking for " + banner + " on port "+ str(port))
print(type(banner))
##<class 'int'>
print(type(port))
portlist =[21,22.80,110]
##<class 'list'>
print(type(portlist))

portOpen=True
##<class 'bool'>
print(type(portOpen),"布尔类型")

print("全大写  " + banner.upper())
print("全小写  " + banner.lower())
print("替换字符串  " + banner.replace("FreeFloat","Ability"))
print("查找字符串位置  " + str(banner.find("FTP")))

#列表
newportlist=[]
newportlist.append(21)
newportlist.append(80)
newportlist.append(443)
newportlist.append(25)
print("\n--------------------列表--------------------\n",newportlist)
newportlist.sort()
print("列表排序",newportlist)
pos=newportlist.index(80)
print("80的索引值",pos)
print("[+] There are " + str(pos) + " ports to scan before 80")
newportlist.remove(443)
print("去掉443之后的值",newportlist)
print("新的列表长度",len(newportlist))
print("\n---------------------字典--------------------------\n")
service = {'ftp':21,'ssh':22,'smtp':25,'http':80}
print("字典信息",service)
print("字典的索引值",service.keys())
print("字典的每一项的值",service.items())
print("字典是否存在ftp这个索引值",service.get('ftp'))
print('取得字典的索引值ftp得值',service['ftp'])
#print("\n---------------------网络--------------------------\n")
#import socket #引入模块，socket
#socket.setdefaulttimeout(2)
#s=socket.socket()
#s.connect(("192.168.1.103",22))
#ans=s.recv(1024)
#print(ans)
print("\n---------------------异常处理--------------------------\n")
print(" 1337/0 的值")
try:
	print("[+] 1337/0 ="+str(1337/0))
except:
	print("[-] have error! ")
print("异常的信息")
try:
	print("[+] 1337/0 ="+str(1337/0))
except Exception as e:
	print("[-] have error! "+str(e))
import socket #引入模块，socket
import traceback
socket.setdefaulttimeout(2)
s=socket.socket()
try:
	s.connect(("192.168.1.103",21))
	ans=s.recv(1024)
	print(ans)
except Exception as e:
	print("异常信息 "+str(e))
	print("\n",traceback.format_exc())